using Gateway.IQuery.User.Result;
using SqlSugar;

namespace Gateway.IQuery.UserMessage.Result;

/// <summary>
/// 用户 message detail result
/// </summary>
[SugarTable("UserMessage")]
public class UserMessageDetailResult : BaseResult
{
    public string UserMessageId { get; set; }

    /// <summary>
    /// 用户名/标识
    /// </summary>
    public string Account { get; set; }

    /// <summary>
    /// 消息
    /// </summary>
    public string Message { get; set; }

    /// <summary>
    /// 消息阅读状态
    /// </summary>
    public string ReadStatus { get; set; }

    /// <summary>
    /// 摘要
    /// </summary>
    public string Intro { get; set; }

    /// <summary>
    /// 消息类型
    /// </summary>
    public string SendType { get; set; }

    /// <summary>
    /// 发送人
    /// </summary>
    public string Sender { get; set; }

    /// <summary>
    /// 完成状态
    /// </summary>
    public string State { get; set; }

    /// <summary>
    /// 结果
    /// </summary>
    public string Result { get; set; }

    /// <summary>
    /// 消息类型
    /// </summary>
    public string MessageType { get; set; }


    /// <summary>
    /// 关联的资源id
    /// </summary>
    public string ResourceId { get; set; }
    
    
    /// <summary>
    /// 用户名
    /// </summary>
    [SugarColumn(IsIgnore = true)]
    public string UserName { get; set; }

    /// <summary>
    /// 用户名
    /// </summary>
    [SugarColumn(IsIgnore = true)]
    public string UserNameF { get; set; }

    /// <summary>
    /// 用户头像
    /// </summary>
    [SugarColumn(IsIgnore = true)]
    public string Avatar { get; set; }

    public void BuildUser(UserDetailResult user)
    {
        if (user == null) return;
        this.UserName = user.UserName;
        this.UserNameF = this.UserName.Substring(0, 1);
        this.Avatar = user.UserAvatar ?? "img/avatar.jpg";
    }
}